def is_valid_brackets(sequence):
    stack = []
    opening_brackets = ['(', '[', '{', '<']
    closing_brackets = [')', ']', '}', '>']
    brackets_map = {')': '(', ']': '[', '}': '{', '>': '<'}
    
    for bracket in sequence:
        if bracket in opening_brackets:
            stack.append(bracket)
        elif bracket in closing_brackets:
            if len(stack) == 0 or brackets_map[bracket] != stack.pop():
                return False
    
    return len(stack) == 0

bracket_sequence = input("Введите скобочную последовательность: ")
is_valid = is_valid_brackets(bracket_sequence)
print(is_valid)
